#!/bin/sh

if [ `uname -m` = armv5tejl ]; then
echo "Setting up ipkg arch-file"
mkdir -p %OPTWARE_TARGET_PREFIX%/etc/ipkg
cat >> %OPTWARE_TARGET_PREFIX%/etc/ipkg/arch.conf << EOF
arch all 1
arch any 6
arch noarch 11
arch arm 16
EOF
fi

touch /etc/profile
if ! grep '^PATH=.*%OPTWARE_TARGET_PREFIX%/bin' /etc/profile >/dev/null 2>&1 ; then
  echo "PATH=%OPTWARE_TARGET_PREFIX%/bin:%OPTWARE_TARGET_PREFIX%/sbin:\$PATH" >> /etc/profile
fi


if ! grep '^# Optware setup' /etc/init.d/rcS >/dev/null 2>&1
then
  echo "Modifying /etc/init.d/rcS"
  [ ! -e /etc/init.d/rcS ] && echo "#!/bin/sh" >/etc/init.d/rcS
  sed -i -e '/^exit 0/d' /etc/init.d/rcS
  cat >>/etc/init.d/rcS <<EOF

# Optware setup
[ -x /etc/init.d/rc.optware ] && /etc/init.d/rc.optware start

exit 0
EOF
  chmod 755 /etc/init.d/rcS
fi
